package leetcode.每日一题;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/11/11 10:41 PM
 * @description：
 */
public class 判断字符串的两半是否相似 {
    @Test
    public void test() {

    }

    class Solution {
        public boolean halvesAreAlike(String s) {
            String a = s.substring(0, s.length() / 2);
            String b = s.substring(s.length() / 2);
            String h = "aeiouAEIOU";
            int sum1 = 0, sum2 = 0;
            for (int i = 0; i < a.length(); i++) {
                if (h.indexOf(a.charAt(i)) >= 0) {
                    sum1++;
                }
            }
            for (int i = 0; i < b.length(); i++) {
                if (h.indexOf(b.charAt(i)) >= 0) {
                    sum2++;
                }
            }
            return sum2 == sum1;
        }
    }
}
